/*
 * CS_REQ_AI_INFO_DEFAULT.cpp
 *
 *  Created on: 2013. 9. 27.
 *      Author: mega@gamevil.com
 */

#include "../../Command.h"
#include "../../User.h"
#include "../../Proxy.h"
#include "../../NLogic/Space.h"
#include "../../NLogic/Function.h"
#include "../../NResource/Static.h"

namespace ProjectZ { namespace NCommand {

void Command::CS_REQ_AI_INFO_DEFAULT(User * pUser, ::Network::Packet * pPacket)
{
	PREPARE_PACKET;

	int oppUserSeq	= 0;

	*pPacket >> oppUserSeq;

	NLogic::Space * pSpace = pUser->GetSpace();
	if (NULL == pSpace)
	{
		DEBUGLOG("CS_REQ_AI_INFO_DEFAULT : pSpace is NULL");
		return;
	}

	User * pDummy = NULL;

	if (true == pSpace->GetData()._bPVPDummyUser)
	{
		pDummy = NResource::Static::InstancePtr()->GetDummyUserResource()->GetDummyUser(pSpace->GetData()._PVPDummyUserSeq);

		if (NULL == pDummy)
		{
			DEBUGLOG("CS_REQ_AI_INFO_DEFAULT : NULL == pDummy");
			return;
		}
	}
	else
	{
		auto iter = ::ProjectZ::NProxy::GetUserTree().find(oppUserSeq);

		if (iter == ::ProjectZ::NProxy::GetUserTree().end())
		{
			DEBUGLOG("CS_REQ_AI_INFO_DEFAULT : iter == GetUserTree().end()");
			return;
		}

		pDummy	= iter->second;
	}

	// AI 유저 위치 설정
//	pDummy->SetCoordinate(PVP_P2_START_X, PVP_P2_START_Y, 180);

	// AI 정보 클라이언트로 전송
	NLogic::NFunction::SendAICharacterDefaultInfo(pDummy, pUser);
	NLogic::NFunction::SendAICharacterEquipInfo(pDummy, pUser);
	NLogic::NFunction::SendAICharacterQuickSlotInfo(pDummy, pUser);
}

} /*NCommand*/ } /*ProjectZ*/


